package com.jc.common.util;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;


/**
 * map根据key第一个字母排序
 */
public class MapKeyComparatorUtil implements Comparator<String> {

    @Override
    public int compare(String str1, String str2) {
        
        return str1.compareTo(str2);
    }


    public static Map<String, Object> sortMapByKey(Map<String, Object> map) {
        if (map == null || map.isEmpty()) {
            return null;
        }
        Map<String, Object> sortMap = new TreeMap<String, Object>(new MapKeyComparatorUtil());
        sortMap.putAll(map);
        return sortMap;
    }

}